
interface charge {
    public double calu(double a);
}

class movie implements charge {
    public movie(boolean VIP) { 
        this.VIP=VIP; 
    }

    public boolean VIP;

    public double calu(double a) {
        double result=0;
        if(a==0)
            result=50;
        else if(a==1)
            result=60;
        else if(a==2)
            result=100;

        if(this.VIP)
            return result/2;
        else
            return result;
    }
}

class texi implements charge {
    public double calu(double a) {
        if(a<3)
            return 8;
        else
        {
            double more=a-3;
            return 8+more/0.8;
        }
    }
}

class park implements charge {
    private double startTime;

    public park(double startTime) { this.startTime=startTime; }

    public double calu(double endTime) { //只能算一天的，所以endTime必须大于startTime，多天就创建多个对象
        double result=0;
        //计算白天停车费
        if(startTime<=20 /*不完全在20-24*/ && endTime>=8 /*不完全在0-8*/ ) //看看有没有白天
        {
            double dayStartTime=startTime;
            double dayEndTime=endTime;
            if(startTime<8) //把0-8的部分截掉
                dayStartTime=8;
            if(endTime>20) //把20-24的部分截掉
                dayEndTime=20;
            result+=4*(dayEndTime-dayStartTime);
        }
        if(startTime<8 || endTime>20)
            result+=10;
        return result;
    }
}

class homework3 {
    public static void main(String[] args) {
        movie a=new movie(true);
        System.out.println(a.calu(1));
        texi b=new texi();
        System.out.println(b.calu(4));
        park c=new park(7);
        System.out.println(c.calu(19));
    }
}